package com.sq.partner.manager.service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.sq.partner.manager.mybatis.model.CoreDept;
import com.sq.partner.manager.mybatis.model.GatewayAuwConfig;
import com.sq.partner.manager.mybatis.model.GatewayAuwProd;
import com.sq.partner.manager.mybatis.model.GatewayChannelInfo;
import com.sq.partner.manager.mybatis.model.RiskAlgMap;
import com.sq.partner.manager.mybatis.model.TradFeeRateAmnt;
import com.sq.partner.manager.mybatis.model.TradFeeRateDay;
import com.sq.partner.manager.mybatis.model.TradFeeRateFixed;
import com.sq.partner.manager.mybatis.model.TradFeeRateMonth;
import com.sq.partner.manager.mybatis.model.TradFeeRiskCommon;
import com.sq.partner.manager.util.Page;

public interface FeeRateService {

	/**
	 * 所有费率表通用批量插入
	 * @param tradFeeRateDay
	 * @throws Exception
	 */
	<T> void batchInsertIntoFeeRate(String statementName, List<T> list) throws Exception;

	/**
	 * 险种通用算法表通用批量插入
	 * @param tradFeeRateDay
	 * @throws Exception
	 */
	boolean batchInsertIntoRiskCommon(List<TradFeeRiskCommon> list);
	
	/**
	 * 往天数费率表中插入数据
	 * @param tradFeeRateDay
	 * @throws Exception
	 */
	void insertIntoFeeRateDay(TradFeeRateDay tradFeeRateDay) throws Exception;

	/**
	 * 查询天数费率表
	 * @param tradFeeRateDay
	 * @return
	 */
	List<TradFeeRateDay> queryTradFeeRateDay(TradFeeRateDay tradFeeRateDay) throws Exception;

	/**
	 * 根据险种代码删除天数费率配置
	 * @param riskCode
	 * @throws Exception
	 */
	void deleteTradFeeRateDayByRiskCode(String riskCode) throws Exception;

	/**
	 * 往月数费率表中插入数据
	 * @param tradFeeRateMonth
	 * @throws Exception
	 */
	void insertIntoFeeRateMonth(TradFeeRateMonth tradFeeRateMonth) throws Exception;

	/**
	 * 查询月数费率表
	 * @param tradFeeRateMonth
	 * @return
	 */
	List<TradFeeRateMonth> queryTradFeeRateMonth(TradFeeRateMonth tradFeeRateMonth) throws Exception;

	/**
	 * 根据险种代码删除月数费率配置
	 * @param riskCode
	 * @throws Exception
	 */
	void deleteTradFeeRateMonthByRiskCode(String riskCode) throws Exception;

	/**
	 * 根据险种id查询固定保费算法表
	 * @return
	 * @throws Exception
	 */
	List<TradFeeRateFixed> queryTradFeeRateFixedById(String riskCode) throws Exception;

	/**
	 * 根据险种id删除固定算法表中的记录
	 * @param riskCode
	 * @throws Exception
	 */
	void delTradFeeRateFixedById(String riskCode) throws Exception;

	/**
	 * 向固定保费表中插入数据
	 * @param feeRateFixed
	 * @throws Exception
	 */
	void insertTradFeeRateFixed(TradFeeRateFixed feeRateFixed) throws Exception;

	/**
	 * 保存数据时  页面表单序列化数据的处理  只用于天数和月数算法
	 * @return
	 * @throws Exception
	 */
	Object getDataListForDayOrMonth(List<Map<String, Object>> arr) throws Exception;

	/**
	 * 根据险种id查询保额计算保费法表
	 * @return
	 * @throws Exception
	 */
	List<TradFeeRateAmnt> queryTradFeeRateRateAmntById(String riskCode) throws Exception;
	
	/**
	 * 查询合作伙伴
	 * 
	 */
	public Page<GatewayChannelInfo> queryPageForGatewayChannelInfo(Page<GatewayChannelInfo> page) throws Exception;
	
	/**
	 * 查询机构
	 * 
	 */
	Page<CoreDept> queryPageForCoreDept(Page<CoreDept> page, String partnerNo) throws Exception;

	/**
	 * 根据险种代码删除保额计算保费法表记录
	 * 
	 */
	public void delTradFeeRateAmntById(String riskCode) throws Exception;

	/**
	 * 添加保额计算保费表
	 * 
	 */
	public void insertTradFeeRateAmnt(TradFeeRateAmnt tradFeeRateAmnt) throws Exception;

	/**
	 * 分页查询所有的核保规则
	 * @return
	 * @throws Exception
	 */
	Page<GatewayAuwConfig> queryAuwConfigsByPage(int size, int pageIndex, String tradProdCode) throws Exception;

	/**
	 * 查询某品已经配置的核保规则
	 * @param tradProdCode
	 * @return
	 * @throws Exception
	 */
	List<GatewayAuwProd> queryAuwConfigsByProd(String tradProdCode) throws Exception;

	/**
	 * 刪除某产品已分配的核保规则
	 * @param tradProdCode
	 */
	void removeAllAuwConfigsFromProd(String tradProdCode) throws Exception;
	/**
	 * 根据险种id查询险种通用算法表
	 * 
	 */
	List<TradFeeRiskCommon> queryTradFeeRiskCommonByMap(Map<String,Object> map) throws Exception;
	/**
	 * 根据险种RiskCode删除表中记录
	 * 
	 */
	void delTradFeeRiskCommonByRiskCode(String tradPlanCode) throws Exception;
	/**
	 * 查询数据库MaxId
	 * 
	 */
	int queryMaxId() throws Exception; 
	/**
	 * 添加险种通用算法(每天保费固定乘以天数)
	 * 
	 */
	void insertTradFeeRiskCommon(TradFeeRiskCommon tradFeeRiskCommon) throws Exception;
	
	/**
	 * 获取险种通用算法保存时的数据List
	 * @param arr
	 * @return
	 * @throws Exception
	 */
	List<TradFeeRiskCommon> getDataListForTradFeeRiskCommon(List<Map<String, Object>> arr) throws Exception;
	
	/**
	 * 通过险种代码查询险种通用算法表
	 * @param riskCode
	 * @return
	 * @throws Exception
	 */
	List<Map<String, Object>> queryTradFeeRiskCommonByRiskCode(String riskCode) throws Exception;
	
	/**
	 * 检验算法对应的方案是否出单
	 * 
	 */
	int checkOpenCalDiv(String tradPlanCode) throws Exception;
	
	/**
	 * 修改操作人和操作时间
	 */
	void updateOps(RiskAlgMap riskAlgMap) throws Exception;
	/***
	 * 新意见险导出规则
	 */
	List<Map<String, Object>> impNlifeAuw(Map<String, Object> map) throws Exception;
	
	/**
	 * 新意健险所有费率表通用批量插入
	 * @param tradFeeRateDay
	 * @throws Exception
	 */
	<T> void addNlifeBatchFeeRate(List<T> list,Map<String, Object> map) throws Exception;

	void deletThiscal(String id ) throws Exception;

	void updateThisCal(String prodCode, String riskCode, String id,
			String covCode, String cond1, String cond2, String cond3,
			String cond7, String cond10,String cond13, double premRate, String unused ,String rationId) throws Exception;

	void insertThisCal(Map<String, Object> map) throws Exception;

	String isExistCal(Map<String, String> map) throws Exception;

	List<Map<String, BigDecimal>> queryCovUse3(Map<String, String> map) throws Exception;
	
	/*
	 * 短期费率回写
	 */
	String writeBackShortRate(Map<String,String> map) throws Exception;

	int queryExistShortRateByMap(Map<String, String> map) throws Exception;

	void updateShortRate(Map<String, String> map) throws Exception;
}
